<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Product extends MY_Controller {

	function Product()
	{
		parent::MY_Controller();
        $this->load->helper('page');
        page_common();
	}

    function more($offset=0) {
        $this->load->model('Mproduct');
        $temp = $this->Mproduct->get_product_types();
        $types = array();
        foreach($temp as $arr){
            $types[$arr['id']] = $arr['type_name'];
        }
        $type = $temp[0]['id'];
        $s_type = parent::get_session_value('product_more_type');
        if($s_type) {
            $type = $s_type;
        }
        if($this->input->post('type')) {
            $type = $this->input->post('type');
            parent::set_session_value('product_more_type',$type);
        }

        $total = $this->Mproduct->get_product_count($type);
        //echo $total;
		$this->load->library('pagination');

		$config['base_url'] = base_url().'product/more/';
		$config['total_rows'] = $total;
		$config['per_page'] = 20;
		$config['uri_segment'] = 3;
		$config['num_links'] = 3;
		$config['full_tag_open'] = '<div class="pagebar">';
		$config['full_tag_close'] = '</div>';
		$config['cur_tag_open'] = '<span class="current">';
		$config['cur_tag_close'] = '</span>';
		$config['first_link'] = '&#171;';
		$config['last_link'] = '&#187;';
		$config['next_link'] = '&gt;';
		$config['prev_link'] = '&lt;';

		$this->pagination->initialize($config);

		$page_html = $this->pagination->create_links();
        $limit = $config['per_page'];
        $products = $this->Mproduct->get_more_product($type,$offset,$limit);
        $this->template->view('v1/product_more',array('products'=>$products,'types'=>$types,'type'=>$type,'page_html'=>$page_html));
    }


}
?>